<template>
  <el-dialog append-to-body title="复核不通过" width="640px" :visible="visible" @close="handleClose">
    <el-form :model="form" :rules="rules" ref="form" class="white-card">
      <!-- <div class="tips">如需回退，请填写回退理由</div> -->
      <el-form-item label="不通过理由：" prop="checkAdvice">
        <el-input v-model="form.checkAdvice" show-word-limit maxlength="500" placeholder="请输入详细描述" type="textarea" :autosize="{ minRows: 6 }"></el-input>
      </el-form-item>
    </el-form>

    <div class="split"></div>

    <div class="dialog-footer-btn">
      <el-button @click="handleClose" type="primary" plain>关闭</el-button>
      <el-button @click="handleSubmit" :loading="submitting" type="primary">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import * as workOrderApi from "@/api/workOrder/index";
import * as mixins from "@/utils/mixins";

export default {
  name: "appealDialog",
  mixins: [mixins.loading, mixins.form, mixins.dialog],
  props: ["visible", "workOrderNo"],
  data() {
    return {
      submitting: false,
      form: {
        checkAdvice: "",
        isPass: 0, // 	复核是否通过 0 不通过 1 通过
        workOrderNo: "",
      },
      rules: {
        checkAdvice: [{ required: true, message: "请填写" }],
      },
      optionList: [],
    };
  },
  methods: {
    handleSubmit() {
      this.validateAndConfirm("form", "确定不通过此次复核？")
        .then(() => {
          this.submitting = true;
          return workOrderApi.process.doRepeatCheck({
            ...this.form,
            workOrderNo: this.workOrderNo,
          });
        })
        .then(() => {
          this.$emit("success");
          this.handleClose();
        })
        .finally(() => (this.submitting = false));
    },
  },
};
</script>

<style lang="less" scoped>
.tips {
  text-align: center;
  margin-bottom: 20px;
}
</style>
